# $Id: PKGBUILD 108456 2014-03-27 14:47:54Z fyan $
# Maintainer: jelle van der Waa <jelle@vdwaa.nl>
# Contributor: Felix Kaiser <felix.kaiser@fxkr.net>

pkgbase=python-mock
pkgname=(python2-mock python3-mock)
pkgver=3.0.5
pkgrel=1
pkgdesc='Mocking and Patching Library for Testing'
url='https://docs.python.org/3/library/unittest.mock.html'
makedepends=('python2' 'python3')
license=('BSD')
arch=('any')
source=("https://pypi.python.org/packages/source/m/mock/mock-$pkgver.tar.gz")
sha256sums=('83657d894c90d5681d62155c82bda9c1187827525880eda8ff5df4ec813437c3')
noextract=(mock-${pkgver}.tar.gz)

prepare() {
  [[ -d ${srcdir}/mock-${pkgver} ]] && rm -rf ${srcdir}/mock-${pkgver}
  tar -xzf ${srcdir}/mock-${pkgver}.tar.gz -C ${srcdir} || true
}

build() {
  cd "$srcdir"
  cp -rf "mock-$pkgver" "mock2-$pkgver"

  cd "$srcdir/mock-$pkgver"
  python3 setup.py build

  cd "$srcdir/mock2-$pkgver"
  python2 setup.py build
}

package_python3-mock() {
depends=('python3')
  cd "$srcdir/mock-$pkgver"
  python3 setup.py install --optimize=1 --root="$pkgdir"
  install -Dm644 LICENSE.txt "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}

package_python2-mock() {
depends=('python2')
  cd "$srcdir/mock2-$pkgver"
  python2 setup.py install --optimize=1 --root="$pkgdir"
  install -Dm644 LICENSE.txt "${pkgdir}"/usr/share/licenses/${pkgname}/LICENSE
}
